# Import
NRX10_raw <-
statgl_url("NRX10", lang = language) %>%
statgl_fetch(
units = "K",
account = "02",
Aar = px_all(),
.col_code = TRUE
) %>%
as_tibble()
# transform
NRX10 <-
NRX10_raw %>%
rename("time" = "Aar") %>%
mutate(time = time %>% as.numeric()) %>%
mutate(value = (value - lag(value)) / lag(value))
NRX10 %>%
ggplot(aes(
x = time,
y = value,
fill = account
)) +
geom_col() +
scale_fill_statgl() +
theme_statgl() +
theme(legend.position = "none") +
scale_y_continuous(labels = scales::percent_format(
scale = 100,
accuracy = 1,
big.mark = ".",
decimal.mark = ","
)) +
labs(
title = sdg8$fig$fig1$title[language],
subtitle = NRX10[[1]][1],
x = " ",
y = sdg8$fig$fig1$y_lab[language],
fill = " ",
caption = sdg8$fig$fig1$cap[language]
)
Statbank, GDP # Import
url <- paste0("https://bank.stat.gl/api/v1/", language, "/Greenland/AR/AR30/ARXBFB05.px")
ARXBFB05_raw <-
url |>
statgl_fetch(
time = px_all(),
municipality = px_all(),
"inventory variable" = "H",
.col_code = T
) |>
as_tibble()
# Transform
ARXBFB05 <-
ARXBFB05_raw %>%
mutate(time = time %>% make_date(),
municipality = municipality %>% factor(levels = unique(municipality)))
# Plot
ARXBFB05 %>%
filter(municipality == ARXBFB05[[1]][1]) %>%
ggplot(aes(
x = time,
y = value,
color = municipality
)) +
geom_line(size = 2) +
facet_wrap(~ municipality, scales = "free") +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 0.1,
big.mark = ".",
decimal.mark = ","
)) +
theme_statgl() +
scale_color_statgl() +
theme(legend.position = "none") +
labs(
title = sdg8$fig$fig2$title[language],
subtitle = ARXBFB05[[1]][1],
x = " ",
y = " ",
caption = sdg8$fig$fig2$cap[language]
)
StatBank # Import
url <- paste0("https://bank.stat.gl/api/v1/", language, "/Greenland/AR/AR40/ARXLED3.px")
ARXLED3_raw <-
url |>
statgl_fetch(
time = px_all(),
district = "AA",
age = "1",
"inventory variable" = "P",
.col_code = TRUE
) %>%
as_tibble()
# Transform
ARXLED3 <-
ARXLED3_raw %>%
mutate(time = time %>% make_date()) %>%
unite(combi, 1, 2, 4, sep = ", ")
# Plot
ARXLED3 %>%
ggplot(aes(
x = time,
y = value,
color = combi
)) +
geom_line(size = 2) +
theme_statgl() +
scale_color_statgl() +
theme(legend.position = "none") +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 0.1,
big.mark = ".",
decimal.mark = ","
)) +
labs(
title = sdg8$fig$fig3$title[language],
subtitle = ARXLED3[[1]][1],
x = " ",
y = " ",
color = " ",
caption = sdg8$fig$fig3$cap[language]
)
StatBank
# Import
url <- paste0("https://bank.stat.gl/api/v1/", language, "/Greenland/AR/AR40/ARXLED3.px")
ARXLED4_raw <-
url |>
statgl_fetch(
time = px_all(),
district = "AA",
"inventory variable" = "P",
age = px_all(),
.col_code = T
) %>%
as_tibble()
# Transform
ARXLED4 <-
ARXLED4_raw %>%
filter(age != ARXLED4_raw[[2]][1]) %>%
arrange(desc(time)) %>%
mutate(age = age %>% factor(levels = unique(age)),
time = time %>% make_date()) %>%
unite(combi, 1, 4, sep = ", ")
# Plot
ARXLED4 %>%
ggplot(aes(
x = time,
y = value,
color = age
)) +
geom_line(size = 1.5) +
theme_statgl() +
scale_color_statgl() +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 1,
big.mark = ".",
decimal.mark = ","
)) +
labs(
title = sdg8$fig$fig4$title[language],
subtitle = ARXLED4[[1]][1],
x = " ",
y = " ",
color = " ",
caption = sdg8$fig$fig4$cap[language]
)
StatBank # Import
url <- paste0("https://bank.stat.gl/api/v1/", language, "/Greenland/AR/AR40/ARXLED3.px")
ARXLED3_raw <-
url |>
statgl_fetch(
time = px_all(),
district = "AA",
age = "1",
"inventory variable" = "P",
"place of residence" = px_all(),
.col_code = TRUE
) %>%
as_tibble()
# Transform
ARXLED3 <-
ARXLED3_raw %>%
mutate(time = time %>% make_date())
# Plot
ARXLED3 %>%
ggplot(aes(
x = time,
y = value,
color = `place of residence`
)) +
geom_line(size = 2) +
theme_statgl() +
scale_color_statgl() +
scale_y_continuous(labels = scales::percent_format(
scale = 1,
accuracy = 1,
big.mark = ".",
decimal.mark = ","
)) +
labs(
title = sdg8$fig$fig5$title[language],
subtitle = ARXLED4[[2]][1],
x = " ",
y = " ",
color = " ",
caption = sdg8$fig$fig5$cap[language]
)
StatBank
# Import
TUXUPAX_raw <-
statgl_url("TUXUPAX", lang = language) %>%
statgl_fetch(airport = 0,
month = 0,
time = px_all(),
.col_code = TRUE) %>%
as_tibble()
# Transform
TUXUPAX <-
TUXUPAX_raw %>%
mutate(value = value / 1000,
time = time %>% make_date())
# Plot
TUXUPAX %>%
ggplot(aes(
x = time,
y = value,
fill = airport
)) +
geom_col() +
theme_statgl() +
scale_fill_statgl() +
theme(plot.margin = margin(10, 10, 10, 10),
legend.position = "none") +
labs(
title = sdg8$fig$fig7$title[language],
x = " ",
y = sdg8$fig$fig7$y_lab[language],
caption = sdg8$fig$fig7$cap[language]
)
StatBank UDXUMG3_raw <-
statgl_url("UDXUMG3", lang = language) %>%
statgl_fetch(
alder = px_all(),
registrering = 5:7,
aar = px_all(),
.col_code = TRUE
) %>%
as_tibble()
#sdg8 <- read_yaml("S:/STATGS/VM/SDG_dokument/input/text/txt_08.yml")
lab_vec <- 1:5
names(lab_vec) <-
c(
"age",
"time",
sdg8$fig$fig8$tags$tag1[language] %>% unlist(),
sdg8$fig$fig8$tags$tag2[language] %>% unlist(),
sdg8$fig$fig8$tags$tag3[language] %>% unlist()
)
UDXUMG3 <-
UDXUMG3_raw %>%
rename("status" = registrering, "age" = alder, "time" = aar) |>
mutate(status = status %>% fct_inorder()) %>%
spread(status, value) %>%
rename(
"age" = 1,
"time" = 2,
"work" = 3,
"none" = 4,
"total" = 5
) %>%
mutate(edu = total - work - none) %>%
select(-total) %>%
rename(lab_vec) %>%
gather(status, value, -c(age, time)) %>%
mutate(time = time %>% as.numeric()) %>%
filter(time %in% c(min(time), mean(time), max(time))) %>%
mutate(time = time %>% as.character() %>% fct_rev())
UDXUMG3 %>%
ggplot(aes(
x = parse_number(age),
y = value,
fill = status
)) +
geom_col(position = "fill") +
facet_wrap(~ time) +
scale_x_continuous(labels = function(x) round(x)) +
scale_y_continuous(labels = scales:: percent) +
scale_fill_statgl(reverse = TRUE) +
theme_statgl() +
labs(
title = sdg8$fig$fig8$title[language],
subtitle = sdg8$fig$fig8$sub[language],
x = sdg8$fig$fig8$x_lab[language],
y = " ",
color = colnames(UDXUMG3_raw)[2] %>% str_to_title(),
caption = sdg8$fig$fig8$cap[language]
)
StatBank